package com.yanqu.road.server.cmd.activity.daomu;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.DaoMuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.daomu.DaoMuActivityModule;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = DaoMuProto.DaoMuRandomSelectSkillListReqMsg.class, respMsg = DaoMuProto.DaoMuRandomSelectSkillListRespMsg.class)
@Cmd(code = Protocol.S_DAOMU_RANDOM_SELECT_SKILL_LIST,desc = "盗墓笔记-PVE-重随技能")
public class DaoMuPveRandomSelectSkillListCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DaoMuProto.DaoMuRandomSelectSkillListReqMsg reqMsg = DaoMuProto.DaoMuRandomSelectSkillListReqMsg.parseFrom(packet.getBytes());
        DaoMuProto.DaoMuRandomSelectSkillListRespMsg.Builder respMsg = player.getModule(DaoMuActivityModule.class).pveRandomSelectSkillList(reqMsg);
        player.sendPacket(Protocol.U_DAOMU_RANDOM_SELECT_SKILL_LIST, respMsg);
        //房间不存在，通知客户端退出房间
        if (respMsg.getRet() == GameErrorCode.E_DAOMU_PVE_ROOM_NOT_EXIST) {
            //通知退出房间
            DaoMuProto.DaoMuDestroyRoomRespMsg.Builder destroyMsg = DaoMuProto.DaoMuDestroyRoomRespMsg.newBuilder();
            destroyMsg.setRet(0);
            player.sendPacket(Protocol.U_DAOMU_PVE_DESTROY_ROOM, destroyMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
